import JSEncrypt from 'jsencrypt';
// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = `MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxffjmP8Tp162HkTYwp8b
ERvPAaBImxaqiilFCxLbD63AObDHNen5BgSP0ameNOc917xtqiho9dqYA8hR1NPm
a16J/Huv1RNvNJcJDpApoz8TVUf+2QHL001KpU9uIU7D9iswmKacsj0WnWm8GulJ
c0vw7Bk4eZJEmnj9rC8NJOOuv5H+q7+I3sfu8nIFA8YvTYpMDTrkPSGA+avYevvr
YOXy5gDjsHDNmI3h5kVtUOI5W0EI4DEA92H11IjaSDOvN8Ga8uC2V1h5/JadND7o
wR7+kt53L+ODhUwxALw1t1QJSxcbCEgleYkkMBTrWCA84T1JgTgstUk/ZeW41Ta3
CwIDAQAB`

const privateKey = `MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDF9+OY/xOnXrYe
RNjCnxsRG88BoEibFqqKKUULEtsPrcA5sMc16fkGBI/RqZ405z3XvG2qKGj12pgD
yFHU0+ZrXon8e6/VE280lwkOkCmjPxNVR/7ZAcvTTUqlT24hTsP2KzCYppyyPRad
abwa6UlzS/DsGTh5kkSaeP2sLw0k466/kf6rv4jex+7ycgUDxi9NikwNOuQ9IYD5
q9h6++tg5fLmAOOwcM2YjeHmRW1Q4jlbQQjgMQD3YfXUiNpIM683wZry4LZXWHn8
lp00PujBHv6S3ncv44OFTDEAvDW3VAlLFxsISCV5iSQwFOtYIDzhPUmBOCy1ST9l
5bjVNrcLAgMBAAECggEAdsoZQuwEQhD93MnY+2d3WVvDailgh9cg/AhpioyE8DKF
PtjJoJtFtwuztM4/xWTgYfyKHWlkGepR/ysLl1aTU+gFioA5cPTZbMgYQinVIkSt
+CVcUaDXSnJ9kRZJcikOQz+FSIPpULaBRHF20vsa/NkbtsAneCOBkON66//Ltk7s
76FT0jlqcgoK8Cph369QryeR+SXCJ5/aSFI+iWLd0B9lqp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PublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

